﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.Common;
using RegisterationCommon.Student;

namespace RegisterationSystem.Space_Student
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //学生家长登录
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            //判断用户密码是否为空
            if (this.txtname.Text == "" || this.txtpwd.Text == "")
            {
                Message.Send(10006);
                return;
            }
            //判断验证码是否正确
            if (Convert.ToString(Session["RBVerifiCode"]).ToLower() != this.VerifCode.Text.ToLower())
            {
                Message.Send(10007);
                return;
            }
            //判断密码是否正确
            if (!StudentInfo.Current.ToLogin(this.txtname.Text.ToLower(), BaseLibrary.ConvertToMD5(this.txtpwd.Text.ToLower())))
            {
                Message.Send(10008);
                return;
            }
            else
            {
                if (!StudentInfo.Current.IsMatured)
                {
                    //不足龄
                    Message.Send(10095);
                }
                //if (StudentInfo.Current.HouseAreaID == 1 && StudentInfo.Current.ScommName == "其他")
                if (StudentInfo.Current.HouseAreaID == 1 && StudentInfo.Current.IsSelf == 1)//市内并是租赁房
                {
                    //市内其他区并且无房产
                    Message.Send(10096);//就近读书
                }
                if (StudentInfo.Current.IsDelete)
                {
                    //已被删除
                    Message.Send(10009);
                }
                else
                {
                    //登录成功
                    Message.Send(10003);
                }
            }
        }
    }
}